Skip to content

fix(memtrack): prompt sudo on interactive stdin#459

Open
not-matthias wants to merge 2 commits into
mainfrom
cod-3153-memtrack-sudo-password-prompt-skipped-when-stdout-is
Open

fix(memtrack): prompt sudo on interactive stdin#459
not-matthias wants to merge 2 commits into
mainfrom
cod-3153-memtrack-sudo-password-prompt-skipped-when-stdout-is

Conversation

@not-matthias

@not-matthias not-matthias commented Jul 17, 2026

Copy link
Copy Markdown
Member

validate_sudo_access previously checked stdin/stdout directly, so both redirected output and piped input could skip the password prompt even when the process still had a controlling terminal. The subsequent non-interactive sudo command then failed when credentials were not cached.

Use /dev/tty to detect whether sudo can prompt through the controlling terminal. Add a Linux integration test that launches a real Bash command with piped stdin and redirected stdout, then verifies a fake sudo receives --validate before the non-interactive command.

Fixes COD-3153

@greptile-apps

greptile-apps Bot commented Jul 17, 2026

Copy link
Copy Markdown

Greptile Summary

This PR fixes sudo prompting for memtrack runs when stdio is redirected. The main changes are:

  • Detects prompt availability through the controlling terminal.
  • Keeps sudo validation disabled when no terminal is available.
  • Adds a Linux integration test for piped stdin and redirected stdout.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
src/executor/helpers/run_with_sudo.rs Switches sudo prompt detection from process stdio to the controlling terminal.
tests/sudo_prompt.rs Adds a Linux integration test that verifies sudo validation with piped input and redirected output.

Reviews (3): Last reviewed commit: "fix(memtrack): detect sudo prompts via c..." | Re-trigger Greptile

Comment thread src/executor/helpers/run_with_sudo.rs Outdated
@codspeed-hq

codspeed-hq Bot commented Jul 17, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

✅ 17 untouched benchmarks


Comparing cod-3153-memtrack-sudo-password-prompt-skipped-when-stdout-is (2915940) with main (26fb4b5)

Open in CodSpeed

@not-matthias
not-matthias force-pushed the cod-3153-memtrack-sudo-password-prompt-skipped-when-stdout-is branch from 50c3e26 to 8c8e200 Compare July 21, 2026 18:21
@not-matthias
not-matthias marked this pull request as ready for review July 21, 2026 18:22
Use the controlling input terminal to decide whether sudo can prompt for a password. Keep the non-interactive wrapper safe after credentials are validated.\n\nFixes COD-3153
Use /dev/tty so piped stdin still prompts when a controlling terminal is available. Add a Bash regression covering piped stdin and redirected stdout.\n\nRefs COD-3153
@not-matthias
not-matthias force-pushed the cod-3153-memtrack-sudo-password-prompt-skipped-when-stdout-is branch from 8c8e200 to 2915940 Compare July 21, 2026 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant